
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
 */

/*
* Carcassonne.java
*
* Created on Feb 16, 2010, 2:14:05 PM
 */
package meeple;

//~--- JDK imports ------------------------------------------------------------

import java.awt.image.BufferedImage;

import java.util.Hashtable;
import java.util.Stack;

import javax.swing.ImageIcon;

/**
 *
 * @author rogier
 */
public class Carcassonne extends javax.swing.JFrame {

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables
    TileData                         tile_data;
    Hashtable<String, BufferedImage> tile_images;
    Stack<Tile>                      tile_stack;
    Map map;
    /** Creates new form Carcassonne */
    public Carcassonne() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setMinimumSize(new java.awt.Dimension(200, 200));
        jPanel1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jPanel1formMouseClicked(evt);
            }
        });
        jPanel1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                jPanel1formMouseMoved(evt);
            }
        });
        jPanel1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jPanel1formKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 484, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 330, Short.MAX_VALUE)
        );

        jMenu1.setText("File");

        jMenuItem1.setText("Start game");
        jMenu1.add(jMenuItem1);

        jMenuItem2.setText("Exit");
        jMenu1.add(jMenuItem2);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 484, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 330, Short.MAX_VALUE)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jPanel1formMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel1formMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jPanel1formMouseClicked

    private void jPanel1formMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel1formMouseMoved
        // TODO add your handling code here:
    }//GEN-LAST:event_jPanel1formMouseMoved

    private void jPanel1formKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jPanel1formKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_jPanel1formKeyPressed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {    // GEN-FIRST:event_jButton2ActionPerformed

        // TODO add your handling code here:
        newGame();
    }                                                                         // GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {    // GEN-FIRST:event_jButton3ActionPerformed

        // TODO add your handling code here:
    }                                                                        // GEN-LAST:event_jButton3ActionPerformed

    private void tileButton1MouseClicked(java.awt.event.MouseEvent evt) {    // GEN-FIRST:event_tileButton1MouseClicked

        // TODO add your handling code here:
        // carcasonneMap1.SetTile(tile_stack.pop());
        // tileButton1.Setimage(tile_images.get(tile_stack.peek().getName()));
    }    // GEN-LAST:event_tileButton1MouseClicked

    private void newGame() {

        // Start new Game
        tile_data   = new TileData();
        tile_stack  = tile_data.createStack();
        tile_images = tile_data.createImages();
        map         = new Map(30, 30);
        map.setRoot(tile_stack.pop());

        // carcasonneMap1.SetImages(tile_images);
        // carcasonneMap1.SetMap(map);
//        tileButton1.Setimage(tile_images.get(tile_stack.peek().getName()));
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Carcassonne().setVisible(true);
            }
        });
    }
}


//~ Formatted by Jindent --- http://www.jindent.com
